package icraf.carbon.gui;

import icraf.carbon.core.AbacusContainer;
import icraf.carbon.core.Project;

import javax.swing.AbstractListModel;
import javax.swing.table.AbstractTableModel;

public class ZoneRowHeaderModel extends AbstractListModel<Object> {
		private static final long serialVersionUID = 7291587098010755608L;
		AbstractTableModel table;
		Project project;

		public ZoneRowHeaderModel(AbstractTableModel table) {
			super();
			this.table = table;
		}

		public Object getElementAt(int index) {
			if (project == null)
				return null;
			if(index > project.getZoneList().getSize()-1) {
				return "TOTAL";
			}
			return project.getZoneList().get(index)
					.getLabel();

		}

		public int getSize() {
			return table.getRowCount();
		}

		public AbacusContainer getProject() {
			return project;
		}

		public void setProject(Project project) {
			this.project = project;
			fireContentsChanged(this, 0, project.getLandCoverList()
					.size() - 1);
		}
	
}
